package com.sinoyd.itszyw.Activity;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.RadioButton;
import android.widget.TextView;

import com.sinoyd.itszyw.Model.MaintainTaskInfo;
import com.sinoyd.itszyw.R;

import org.xutils.view.annotation.ContentView;
import org.xutils.view.annotation.ViewInject;

import static com.sinoyd.itszyw.MyApplication.loginName;

/**
 * @author: Sinoyd 大饼洲
 * @description:
 * @projectName: ITSZYW
 * @creationDate: 2017-03-16 09:45
 */
@ContentView(R.layout.activity_task_detail)
public class MaintainTaskDetailActivity extends BaseActivity  {

    @ViewInject(R.id.task_name)
    private TextView task_name;
    @ViewInject(R.id.task_type_name)
    private TextView task_type_name;
    @ViewInject(R.id.linear_hardware)
    private LinearLayout linear_hardware;
    @ViewInject(R.id.hardware_name)
    private TextView hardware_name;
    @ViewInject(R.id.task_issuer)
    private TextView task_issuer;
    @ViewInject(R.id.issue_date)
    private TextView issue_date;
    @ViewInject(R.id.task_handler)
    private TextView task_handler;
    @ViewInject(R.id.start_date)
    private TextView start_date;
    @ViewInject(R.id.finish_date)
    private TextView finish_date;
    @ViewInject(R.id.task_repairs_dep)
    private TextView task_repairs_dep;
    @ViewInject(R.id.task_repairs)
    private TextView task_repairs;
    @ViewInject(R.id.task_specification)
    private TextView task_specification;
    @ViewInject(R.id.resolved)
    private RadioButton resolved;
    @ViewInject(R.id.unsolved)
    private RadioButton unsolved;
    @ViewInject(R.id.task_description)
    private TextView task_description;


    @ViewInject(R.id.txt_title)
    private TextView txt_title;
    @ViewInject(R.id.linear_back)
    private LinearLayout linear_back;

    private MaintainTaskInfo taskInfo;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        initView();

    }

    private void initView() {



        txt_title.setText(this.getResources().getString(R.string.task_details));
        linear_back.setVisibility(View.VISIBLE);
        taskInfo = (MaintainTaskInfo) getIntent().getSerializableExtra("task");
        task_name.setText(taskInfo.name);
        task_type_name.setText(taskInfo.typeName);
        hardware_name.setText(taskInfo.hardwareName);
        task_issuer.setText(taskInfo.issuer);
        issue_date.setText(taskInfo.issueDate);
        // TODO: 2017/4/7   添加任务开始时间
        start_date.setText(taskInfo.startDate);
        finish_date.setText(taskInfo.finishDate);
        task_handler.setText(loginName);
        task_repairs_dep.setText(taskInfo.repairsDep);
        task_repairs.setText(taskInfo.repairs);
        task_specification.setText(taskInfo.specification);
        task_description.setText(taskInfo.description);
        task_issuer.setText(taskInfo.issuer);
        finish_date.setText(taskInfo.finishDate);
        task_specification.setText(taskInfo.specification);

        if (taskInfo.sloved.equals("true")) {
            resolved.setChecked(true);
        } else {
            unsolved.setChecked(true);
        }
        linear_hardware.setVisibility(taskInfo.typeName.equals("硬件") ? View.VISIBLE : View.GONE);

        linear_back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });

    }
}